{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import re\n",
    "\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from pylab import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pythonlib import boolean as boolean\n",
    "from pythonlib import boolean_net as boolean_net"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random as random #random could be destroyed by matplotlib"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def to_bool_charactor(c):\n",
    "    if c=='1':\n",
    "        return True\n",
    "    else:\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def to_bool_string(s):\n",
    "    return[to_bool_charactor(x) for x in s]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def file2matrix(path):\n",
    "    fp=open(path,'r')\n",
    "    content=fp.read()\n",
    "    rowlist=content.splitlines()\n",
    "    x=np.array([to_bool_string(x) for x in rowlist])\n",
    "    \n",
    "    return x\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "def show_nn(bl1):\n",
    "    fig,axs=plt.subplots(nrows=1, ncols=5, figsize=(12, 6))\n",
    "    axs[0].imshow(np.array([bl1.inode]),vmin=0,vmax=1)\n",
    "    axs[0].set_title('inode')\n",
    "    axs[0].set_axis_off()\n",
    "    axs[1].imshow(bl1.wi,vmin=0,vmax=1)\n",
    "    axs[1].set_title('wi')\n",
    "    axs[1].set_axis_off()\n",
    "    axs[2].imshow(np.array([bl1.hnode]),vmin=0,vmax=1)\n",
    "    axs[2].set_title('hnode')\n",
    "    axs[2].set_axis_off()\n",
    "    axs[3].imshow(bl1.wo,vmin=0,vmax=1)\n",
    "    axs[3].set_title('wo')\n",
    "    axs[3].set_axis_off()\n",
    "    axs[4].imshow(np.array([bl1.onode]),vmin=0,vmax=1)\n",
    "    axs[4].set_title('onode')\n",
    "    axs[4].set_axis_off()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def show_nparray(nparray):\n",
    "    fig,axs=plt.subplots(nrows=1, ncols=1)\n",
    "    axs.imshow((nparray),vmin=0,vmax=1)\n",
    "    axs.set_title('array')\n",
    "    axs.set_axis_off()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "def to_char_bool(bool):\n",
    "    if bool:\n",
    "        return '1'\n",
    "    else:\n",
    "        return '0'\n",
    "\n",
    "def to_string_boollist(boollist):\n",
    "    temp=[to_char_bool(x) for x in boollist]    \n",
    "    return ''.join(temp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 262,
   "metadata": {},
   "outputs": [],
   "source": [
    "bl1=boolean_net.booleannet('bl.db',6,2,3)\n",
    "bl1_mirr=boolean_net.booleannet('bl.db',3,2,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 263,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAqwAAADLCAYAAACrrMH7AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAMuElEQVR4nO3da6xl5V3H8d9/uIiCLZS2wkCZCgOlNdExtmkhImMCUmWoLxqwbXoBE98YbYzVRo1Rqm2sia2KtqYxtQi9KFOqKQMJHYM9Qk0orb1EDGXqZMZTZkYYLuVieqHn8cV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9aqOCWgtfbS8eE/Tb2+K0lNPD/ozXvHbQ9kuLjqUN/xtSSXPsepAgDwDK2ZI6wAAKxMghUAgK4JVgAAuiZYAQDommAFAKBrh71LQM+rF/HMrTtlh9WLAIAVxxFWAAC6JlgBAOiaYAUAoGuCFQCArglWAAC6JlgBAOiaYAUAoGuHvQ8rzMIl6zcd0c+7dc+Xj+jn9epI/9wAoBeOsAIA0DXBCgBA1wQrAABdE6wAAHRNsAIA0DXBCgBA1wQrAABdE6wAAHRNsAIA0DXBCgBA1w67NOu6U3bUck0EAAAOxhFWAAC6JlgBAOiaYAUAoGuCFQCArglWAAC6JlgBAOiaYAUAoGuCFQCArh124QB4uo7kIhPbF47UJ60tfm7AWrN9YasFjp6hlfq7whFWAAC6JlgBAOiaYAUAoGuCFQCArglWAAC6JlgBAOiaYAUAoGuCFQCArglWAAC6Vq21Wc8BAA6wsO/sNfHL6ZL1m2Y9hWVhRSqeK0dYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBrghUAgK4JVgAAuiZYAQDoWrXWZj0HAAA4JEdYAQDommAFAKBrghUAgK4JVgAAuiZYAQDommAFAKBr/wvMvqNO+EbTqgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 864x432 with 5 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "bl1.feedforward()\n",
    "inputs=bl1.inode\n",
    "targets=bl1.onode\n",
    "show_nn(bl1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 264,
   "metadata": {},
   "outputs": [],
   "source": [
    "verify_set=[]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 272,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[False, True, False] [True, True, True, True, True, False]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAABWCAYAAABsOEXAAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAADW0lEQVR4nO3cPezdUxzH8c+nDEKkhEQQTDbCxMIgBoOF0UMaFqFhsJk8JTbCRljqIRJsEhaDhRg1IhZhMSBCihBTj+F/K0XVU/u9Va/XdHN+T+e3vHPuucntWisAzNi17QkA/J+ILsAg0QUYJLoAg0QXYJDoAgwSXYBBogswSHT5T2h76hHGTtnGXODfEF22qu0DbT9p+33bj9revBm/o+27bZ9s+3WSh9vua/t02zfb/pDkurY3tn2/7XdtP2v78GH3fqPtfb953geHngHbILps2ydJrk2yO8kjSV5qe/7m2NVJPk1yXpLHNmO3bj6fmeSdJD8k2ZPkrCQ3Jrmn7U2bc59PcvuhB7W9IsmFSd44bm8Df6L+e4ETSdv9SR5KcnaSR9daFx92bF+SXWutPUe5/qkka611f9vTknye5Kq11sdtH09y+lpr73F8BTgqK122qu2etvvbHmh7IMllSc7dHP7sCJf8aqzt1W3fbvtV22+T3H3o+rXWT0leSXJ7211Jbkny4nF6FfhLRJetaXtJkueS3JvknLXWWUk+TNLNKUf6GvbbsZeTvJ7korXW7iTPHHZ9srPFcFuS65P8uNZ675i9APwDoss2nZGdiH6VJG3vzM5K9+84M8k3a62f2l6VnT3fX2wiezDJE7HK5QQgumzNWuuj7MTwvSRfJrk8ybt/8zZ7kzza9vskDyZ59QjnvLC590v/fLZwbPghjZNe2z1J7lprXbPtuYCVLie1tqdnZzX87LbnAonochJre0N29ou/zM4PbrB1thcABlnpAgwSXYBBv/vnpsMd/OJSew/AMXfDBVduewrH1VsHX+sfHbPSBRgkugCDRBdgkOgCDBJdgEGiCzBIdAEGiS7AINEFGCS6AINEF2CQ6AIMEl2AQaILMEh0AQaJLsAg0QUYJLoAg0QXYJDoAgwSXYBBogswSHQBBokuwCDRBRgkugCDRBdgkOgCDBJdgEGiCzBIdAEGiS7AINEFGCS6AINEF2CQ6AIMEl2AQaILMEh0AQaJLsAg0QUYJLoAg0QXYJDoAgwSXYBBogswSHQBBokuwCDRBRgkugCDRBdgkOgCDBJdgEGiCzBIdAEGda217TkA/G9Y6QIMEl2AQaILMEh0AQaJLsAg0QUY9DMnuYh34Pf4PwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAACOCAYAAACSVduCAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEMElEQVR4nO3cy+vlcxzH8ddrWIiEKCH8A8SKDQtJFrNhYeHSxEaIhZ2VW9kRO2IzLinsFCULG7I0STZio0gTuTSymo/F74wG4zbM+zAej9Xp8719vptnn/M5dbrWCgAzdm17AgD/J6ILMEh0AQaJLsAg0QUYJLoAg0QXYJDoAgwSXf4T2p54hLETtjEX+DtEl61qe1/bj9t+1/bDttdvxm9t+07bx9t+meTBtnvbPtn29bYHklzVdnfb99p+2/bTtg8edu/X2t7zi+e9f+gZsA2iy7Z9nOTKJKcleSjJC23P2Ry7PMknSc5O8shm7KbN51OT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HQBBokuwCDRBRgkugCDRBdg0I//oInn+RSjEwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "inputs=((np.random.rand(1,6))>0.5).flatten().tolist()\n",
    "targets=((np.random.rand(1,3))>0.5).flatten().tolist()\n",
    "print(targets,inputs)\n",
    "verify_set.append([targets,inputs])\n",
    "#show_nparray(np.array(inputs))\n",
    "show_nparray(np.array([inputs]))\n",
    "show_nparray(np.array([targets]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 232,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[[True, False, True], [True, True, True, True, True, True]],\n",
       " [[True, False, False], [False, False, False, True, True, True]],\n",
       " [[True, False, False], [False, False, False, False, True, False]],\n",
       " [[True, False, False], [False, True, True, True, False, False]]]"
      ]
     },
     "execution_count": 232,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "verify_set"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 260,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAqwAAACRCAYAAAAGuepqAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAALkklEQVR4nO3de6xlV10H8O9v6FS0FSgFrENhoB3Kw0THWOQRJjMaakELxGhrIaW0Pv4wsURFiRqjRSFiIj7QYowRKhUfjGhCH8k4puHaRlMEKcQa6JDJ1IGZyvQx9GEEprP8Y+9Lzhzn3lbm3HvWvffzSW7m7LPP2nvtm5s937vu2r9VrbUAAECvNs27AwAAsByBFQCArgmsAAB0TWAFAKBrAisAAF0TWAEA6JrACt+gqnqkqs6bdz8AYL0rdVgBAOiZEVYAALomsMKUq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AAuiawAgDQtWUXDgBONMtC2gCcGouRbBxGWAEA6JrACgBA1wRWAAC6JrACANA1gRUAgK4JrAAAdE1gBQCgawIrAABdE1gBAOiala4A6M6mc/bNbAWjvcdndaSNxfeNnhhhBQCgawIrAABdE1gBAOiawAoAQNcEVgAAuiawAgDQNYEVAICuCawAAHRNYAUAoGtWuqI7ew7dOe8uLGmWfbt4y/aZHSvp+/sGAKfCCCsAAF0TWAEA6JrACgBA1wRWAAC6JrACANA1gRUAgK4JrAAAdE1gBQCgawIrAABdE1gBAOiawAoAQNcEVgAAuiawAgDQNYEVAICuCawAAHRNYAUAoGsCKwAAXRNYAQDoWrXW5t0HAABYkhFWAAC6JrACANA1gRUAgK4JrAAAdE1gBQCgawIrAABd+1/nAca7Zgm34QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 864x432 with 5 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "for i in range(0,2):\n",
    "    bl1.train(inputs,targets)\n",
    "    bl1.feedforward()\n",
    "    #show_nn(bl1)\n",
    "    #copy weight matrix\n",
    "    bl1_mirr.wi=bl1.wo.T\n",
    "    bl1_mirr.wo=bl1.wi.T\n",
    "    #target as inputs\n",
    "    bl1_mirr.train(targets,inputs)\n",
    "    bl1_mirr.feedforward()\n",
    "    #show_nn(bl1_mirr)\n",
    "\n",
    "    bl1.wi=bl1_mirr.wo.T\n",
    "    bl1.wo=bl1_mirr.wi.T\n",
    "    bl1.feedforward()\n",
    "show_nn(bl1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 299,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "target:  [False, False, True]   result:  [False, False, False]  wrong\n",
      "target:  [True, True, True]   result:  [False, False, False]  wrong\n",
      "target:  [False, False, True]   result:  [False, False, False]  wrong\n",
      "target:  [True, False, False]   result:  [False, False, False]  wrong\n",
      "target:  [False, False, True]   result:  [True, True, False]  wrong\n",
      "target:  [False, True, False]   result:  [False, False, False]  wrong\n",
      "target:  [True, True, True]   result:  [False, False, False]  wrong\n",
      "target:  [True, True, False]   result:  [True, True, False]  right\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 299,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.shuffle(verify_set)\n",
    "for j in verify_set:\n",
    "    inputs=j[1]\n",
    "    targets=j[0]\n",
    "    for i in range(0,2):\n",
    "        bl1.train(inputs,targets)\n",
    "        bl1.feedforward()\n",
    "        #show_nn(bl1)\n",
    "        #copy weight matrix\n",
    "        bl1_mirr.wi=bl1.wo.T\n",
    "        bl1_mirr.wo=bl1.wi.T\n",
    "        #target as inputs\n",
    "        bl1_mirr.train(targets,inputs)\n",
    "        bl1_mirr.feedforward()\n",
    "        #show_nn(bl1_mirr)\n",
    "\n",
    "        bl1.wi=bl1_mirr.wo.T\n",
    "        bl1.wo=bl1_mirr.wi.T\n",
    "        bl1.feedforward()\n",
    "    \n",
    "\n",
    "#test\n",
    "right=0\n",
    "right_list=[]\n",
    "for i in verify_set:\n",
    "    bl1.inode=i[1]\n",
    "    bl1.feedforward() \n",
    "    target=i[0]\n",
    "    result=bl1.onode\n",
    "    if bl1.onode==i[0]:\n",
    "        print('target: ',target , '  result: ',result,' right')\n",
    "        right_list.append(target)\n",
    "        right+=1\n",
    "    else:\n",
    "        print('target: ',target , '  result: ',result,' wrong')\n",
    "right"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 300,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAqwAAADLCAYAAACrrMH7AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAMnklEQVR4nO3df8yd5V3H8c+3tIiCG4xtjsLohI6x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YdVZNsD6Dm/f+SoZzXB9Icm2Sj06M3Z/kZzJcbLVnfM8fJ/m+JZo+AMCqtSJOCWitvWR8+I9Tr+9KUhPPD3nz3nHbQxkurjrcd3wtyaVHOVUAAP6fVs0RVgAAlifBCgBA1wQrAABdE6wAAHRNsAIA0LUj3iVgtawg0fOqD8eS1YsAgOXIEVYAALomWAEA6JpgBQCga4IVAICuCVYAALomWAEA6JpgBQCga0e8DyvMQs/3xb11z92znsJh9fzvBgBHwxFWAAC6JlgBAOiaYAUAoGuCFQCArglWAAC6JlgBAOiaYAUAoGuCFQCArglWAAC6JlgBAOjaEZdmXfOiHbVUE5ml7QdmPQMAAA7HEVYAALomWAEA6JpgBQCga4IVAICuCVYAALomWAEA6JpgBQCga4IVAICuHXHhAHimth/YuioWmeiZBTCA1Wa1LHB0LC3X3wpHWAEA6JpgBQCga4IVAICuCVYAALomWAEA6JpgBQCga4IVAICuCVYAALomWAEA6Fq11mY9BwA4yMVrLl8VP0637rl71lNYElak4mg5wgoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXROsAAB0TbACANA1wQoAQNeqtTbrOQAAwGE5wgoAQNcEKwAAXROsAAB0TbACANA1wQoAQNcEKwAAXfsf+qmiTjHStaMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 864x432 with 5 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "show_nn(bl1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAssAAACiCAYAAAC3bIBgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAACqxJREFUeJzt3G2spGddx/Hff+kikQqUBYUt3QW65clE1wQCVkn7wlqxW3yBLZRIBZU3RowRJWp8AIWoiaBWizFEQcqTW+EFsI3rJupqYwIVUogSpLXpuna70gcKbY1Au39fzH3S8XSv7taec2bO7ueTNJ0z91wz192eXPM999z3VHcHAAB4uC2LngAAACwrsQwAAANiGQAABsQyAAAMiGUAABgQywAAMCCWYZOqqvuq6rmLngcAnMrK9ywDAMDxObIMAAADYhmWTFW9oao+MffzzVW1d+7nw1W1u6q6qnYtZpbAsnsUa8n5VXVDVX11+vf5i5kxLCexDMvnYJKXV9WWqnpmkq1Jvi9JpnOUz0zy+QXOD9gcTmYt+Y8k+5JclWRbkncl2VdV2xYzZVg+YhmWTHffkuTeJLuTXJBkf5LbquoF08//2N3HFjhFYBM4mbUkySVJburua7r7ge7+cJIvJrl0QdOGpXPGoicAHNfBJBcm2TXdviezN7fvnX4GOBknWku2Jzm0asyhJGdv3BRhuTmyDMtp5Q3u5dPtg5m9wV0QsQycvBOtJUeS7Fw1ZkeS2zZuirDcfHUcLKGqel6SzyT5r+7eVVVPSnJrZp8GndXdD1ZVJzmvu29e4FSBJXaitSTJU5L8e5KfTrI3yauS/GmSXd1950ImDUvGaRiwhLr7S1V1X2bnFKa7v1ZVtyS5o7sfXOzsgM3iJNaSu6pqT5I/TPInSW5Oskcow0McWQYAgAHnLAMAwIBYBgCAAbEMAAADYhkAAAZ8Gwab3kVbLlvaq1T3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AANiGQAABsQyAAAMiGUAABgQywAAMCCWAQBgQCwDAMCAWAYAgAGxDAAAA2IZAAAGxDIAAAyIZQAAGBDLAAAwIJYBAGBALAMAwIBYBgCAAbEMAAADYhkAAAbEMgAADIhlAAAYEMsAADAglgEAYEAsAwDAQHX3oucAj8lFWy5b2l/i/UduXPQUjuvi7bsXPYWhA8eurUXPgdPbsaPnLe2asqysKZzKHFkGAIABsQwAAANiGQAABsQyAAAMiGUAABgQywAAMCCWAQBgQCwDAMCAWAYAgAGxDAAAA2IZAAAGxDIAAAyIZQAAGBDLAAAwIJYBAGBALAMAwIBYBgCAAbEMAAADYhkAAAbEMgAADIhlAAAYEMsAADAglgEAYEAsAwDAgFgGAIABsQwAAANiGQAABsQyAAAMiGUAABgQywAAMCCWAQBgQCwDAMCAWAYAgAGxDAAAA2IZAAAGxDIAAAyIZQAAGBDLAAAwUN296DkAAMBScmQZAAAGxDIAAAyIZQAAGBDLAAAwIJYBAGBALAMAwIBYBgCAAbEMAAADYhkAAAbEMgAADIhlAAAYEMsAADAglgEAYEAsAwDAgFgGAIABsQwAAANiGQAABsQyAAAMiGUAABgQywAAMCCWAQBgQCwDAMCAWAYAgIH/BTyne0pU1F1xAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 864x432 with 5 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "bl1_mirr.wi=bl1.wo.T\n",
    "bl1_mirr.wo=bl1.wi.T\n",
    "\n",
    "bl1_mirr.train(bl1.onode,bl1.inode)\n",
    "\n",
    "bl1_mirr.feedforward()\n",
    "show_nn(bl1_mirr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAssAAACiCAYAAAC3bIBgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUA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wAAANiGQAABsQyAAAMiGUAABgQywAAMCCWAQBgQCwDAMCAWAYAgAGxDAAAA2IZAAAGxDIAAAyIZQAAGBDLAAAwIJYBAGBALAMAwIBYBgCAAbEMAAADYhkAAAbEMgAADIhlAAAYEMsAADAglgEAYEAsAwDAgFgGAIABsQwAAANiGQAABsQyAAAMiGUAABgQywAAMCCWAQBgQCwDAMCAWAYAgAGxDAAAA2IZAAAGxDIAAAyIZQAAGBDLAAAwUN296DkAAMBScmQZAAAGxDIAAAyIZQAAGBDLAAAwIJYBAGBALAMAwIBYBgCAAbEMAAADYhkAAAbEMgAADIhlAAAYEMsAADAglgEAYEAsAwDAgFgGAIABsQwAAANiGQAABsQyAAAMiGUAABgQywAAMCCWAQBgQCwDAMCAWAYAgIH/A8KYd7mZ9fxvAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 864x432 with 5 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    " #copy back origin nn weight\n",
    "bl1.wi=bl1_mirr.wo.T\n",
    "bl1.wo=bl1_mirr.wi.T   \n",
    "bl1.feedforward()\n",
    "show_nn(bl1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
